home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / andere sprachen / python-1.3 / docs / what_is_python.txt < prev   
Encoding:
Text File  |  1996-07-16  |  10.2 KB  |  247 lines

  1. What is Python?
  2. ---------------
  3.  
  4. Python is an interpreted, interactive, object-oriented programming
  5. language.  It incorporates modules, exceptions, dynamic typing, very
  6. high level dynamic data types, and classes.  Python combines
  7. remarkable power with very clear syntax.  It has interfaces to many
  8. system calls and libraries, as well as to various window systems, and
  9. is extensible in C or C++.  It is also usable as an extension language
  10. for applications that need a programmable interface.  Finally, Python
  11. is portable: it runs on many brands of UNIX, on the Mac, and on
  12. MS-DOS.
  13.  
  14. As a short example of what Python looks like, here's a script to
  15. print prime numbers (not blazingly fast, but readable!).  When this
  16. file is made executable, it is callable directly from the UNIX shell
  17. (if your system supports #! in scripts and the python interpreter is
  18. installed at the indicated place).
  19.  
  20. #!/usr/local/bin/python
  21.  
  22. # Print prime numbers in a given range
  23.  
  24. def main():
  25.     import sys
  26.     min, max = 2, 0x7fffffff
  27.     if sys.argv[1:]:
  28.         min = int(eval(sys.argv[1]))
  29.         if sys.argv[2:]:
  30.             max = int(eval(sys.argv[2]))
  31.     primes(min, max)
  32.  
  33. def primes(min, max):
  34.     if 2 >= min: print 2
  35.     primes = [2]
  36.     i = 3
  37.     while i <= max:
  38.         for p in primes:
  39.             if i%p == 0 or p*p > i: break
  40.         if i%p <> 0:
  41.             primes.append(i)
  42.             if i >= min: print i
  43.         i = i+2
  44.  
  45. main()
  46.  
  47.  
  48.  
  49. ------------------------------------------------------------------------
  50.  
  51. Newsgroups: comp.lang.perl,comp.lang.tcl
  52. From: lutz@xvt.com (Mark Lutz)
  53. Subject: Python (was Re: Has anyone done a tk addition to perl?)
  54. Organization: XVT Software Inc.
  55. Date: Thu, 14 Oct 1993 17:10:37 GMT
  56. X-Disclaimer: The views expressed in this message are those of an
  57.     individual at XVT Software Inc., and do not necessarily
  58.     reflect those of the company.
  59.  
  60.  
  61. I've gotten a number of requests for information about Python,
  62. since my post here earlier this week.  Since this appears to be 
  63. of general interest, and since there's no python news group yet, 
  64. I'm posting a description here.  I'm not the best authority on 
  65. the language, but here's my take on it.  
  66.  
  67. [TCL/Perl zealots: this is informational only; I'm not trying to
  68. 'convert' anybody, and don't have time for a language war :-)
  69. There is a paper comparing TCL/Perl/Python/Emacs-Lisp, which is
  70. referenced in the comp.lang.misc faq, I beleive.]
  71.  
  72.  
  73. What is Python?...
  74.  
  75. Python is a relatively new very-high-level language developed 
  76. in Amsterdam.  Python is a simple, procedural language, with 
  77. features taken from ABC, Icon, Modula-3, and C/C++.
  78.  
  79. It's central goal is to provide the best of both worlds: 
  80. the dynamic nature of scripting languages like Perl/TCL/REXX, 
  81. but also support for general programming found in the more 
  82. traditional languages like Icon, C, Modula,...
  83.  
  84. As such, it can function as a scripting/extension language,
  85. as a rapid prototyping language, and as a serious software
  86. development language.  Python is suitable for fast development
  87. of large programs, but also does well at throw-away shell coding.
  88.  
  89. Python resembles other scripting languages a number of ways:
  90.     - dynamic, interpretive, interactive nature
  91.     - no explicit compile or link steps needed
  92.     - no type declarations (it's dynamically typed)
  93.     - high-level operators ('in', concatenation, etc)
  94.     - automatic memory allocation/deallocation (no 'pointers')
  95.     - high level objects: lists, tuples, strings, associative arrays
  96.     - programs can construct and execute program code using strings
  97.     - very fast edit/compile/run cycle; no static linking
  98.     - well-defined interface to and from C functions and data
  99.     - well-defined ways to add C modules to the system and language
  100.  
  101. Python's features that make it useful for serious programming:
  102.     - it's object-oriented;  it has a simplified subset of 
  103.       C++'s 'class' facility, made more useful by python's
  104.       dynamic typing;  the language is object-oriented from
  105.       the ground up (rather than being an add-on, as in C++)
  106.  
  107.     - it supports modules (imported packages, as in Modula-3);
  108.       modules replace C's 'include' files and linking, and allow
  109.       for multiple-module systems, code sharing, etc.;
  110.  
  111.     - it has a good exception handling system (a 'try' statement,
  112.       and a 'raise' statement, with user-defined exceptions);
  113.  
  114.     - it's orthogonal;  everything is a first-class object in the
  115.       language (functions, modules, classes, class instance methods...)
  116.       and can be assigned/passed and used generically;
  117.  
  118.     - it's fairly run-time secure;  it does many run-time checks
  119.       like index-out-of-bounds, etc., that C usually doesn't;
  120.  
  121.     - it has general data structuring support;  Python lists are
  122.       heterogeneous, variable length, nestable, support slicing, 
  123.       concatenation, etc., and come into existance and are reclaimed 
  124.       automatically;  strings and dictionaries are similarly general;
  125.  
  126.     - it's got a symbolic debugger and profiler (written in python, 
  127.       of course..), and an interactive command-line interface;
  128.       as in Lisp, you can enter code and test functions in isolation,
  129.       from the interactive command line (even linked C functions);
  130.  
  131.     - it has a large library of built-in modules;  it has support
  132.       for sockets, regular expressions, posix bindings, etc.
  133.  
  134.     - it supports dynamic loading of C modules on many platforms;
  135.  
  136.     - it has a _readable_ syntax;  python code looks like normal
  137.       programming languages;  tcl and perl can be very unreadable
  138.       (IMHO; what was that joke about Perl looking the same after
  139.       rot13..);  python's syntax is simple, and statement based;
  140.  
  141.  
  142. Of course, Python isn't perfect, but it's a good compromise betweem
  143. scripting languages and traditional ones, and so is widely applicable. 
  144. 'Perfect' languages aren't always useful for real-world tasks (Prolog, 
  145. for example), and languages at either extreme are not useful in the other 
  146. domain (C is poor for shell coding and prototyping, and awk is useless 
  147. for large systems design; Python does both well).  
  148.  
  149. For example, I've used Python successfully for a 4K line expert system 
  150. shell project; it would have been at least twice as large in C, and would 
  151. have been very difficult in TCL or Perl.
  152.  
  153. Python uses an indentation-based syntax which may seem unusual at first
  154. to C coders, but after using it I have found it to be _very_ handy, since 
  155. there's less to type.  [I now forget to type '}' in my C code, and am 
  156. busy calculating how much time I wasted typing all those '}', 'END', etc., 
  157. just to pander to 'brain-dead' C/Pascal compilers :-)].
  158.  
  159. Python's currently at release 0.9.9.  It seems suprisingly stable.
  160. The first 'official' 1.0 release is due out by the end of this year.
  161. Python runs on most popular machines/systems (mac, dos, unix, etc.)
  162. It's public domain and distributable, and can be had via ftp.  The 
  163. distribution includes examples, tutorials, and documentation.   The 
  164. latest ftp address I have (I got it on a cd-rom):
  165.     pub/python/*  at  ftp.cwi.nl
  166.     pub/?         at  wuarchive.wustl.edu   (in america)
  167.  
  168. There's a python mailing list maintained by the language's creator.  
  169. Mail 'python-list-request@cwi.nl' to get on it.  
  170.  
  171. Mark Lutz
  172. lutz@xvt.com
  173.  
  174.  
  175. ------------------------------------------------------------------------------
  176.  
  177. Newsgroups: comp.lang.misc,comp.lang.c,comp.lang.c++,comp.lang.perl,comp.lang.tcl
  178. Followup-to: comp.lang.misc
  179. Subject: Python 1.0.0 is out!
  180.  
  181. --> Tired of decyphering the Perl code you wrote last week?
  182.  
  183. --> Frustrated with Bourne shell syntax?
  184.  
  185. --> Spent too much time staring at core dumps lately?
  186.  
  187. Maybe you should try Python, the next generation object-oriented
  188. scripting and prototyping language, with a *readable* syntax.  Python
  189. has been used by hundreds of happy users all over the world during the
  190. past three years, and is now ready for prime time.
  191.  
  192. Python is an interpreted language, and has the usual advantages of
  193. such languages, such as run-time checks (e.g. bounds checking),
  194. execution of dynamically generated code, automatic memory allocation,
  195. high level operations on strings, lists and dictionaries (associative
  196. arrays), and a fast edit-compile-run cycle.  Additionally, it features
  197. modules, classes, exceptions, and dynamic linking of extensions
  198. written in C or C++.  It has arbitrary precision integers.
  199.  
  200. Python can be run interactively, and there is an extensive Emacs
  201. editing mode which includes the capability to execute regions of code.
  202. For the truly desperate there is a source level debugger (written in
  203. Python, of course :-).
  204.  
  205. Python comes with a large library of standard modules and classes, as
  206. well as an extensive set of demo programs.  It has interfaces to most
  207. Unix system calls and library functions, and there exist extensions
  208. that interface to window systems and graphics libraries like X and
  209. SGI's GL.
  210.  
  211. Python's source (in C) and documentation (in LaTeX and PostScript) are
  212. freely available on the Internet.  It builds without intervention on
  213. most Unix platforms: error-free builds have been confirmed for SGI
  214. IRIX 4 and 5, Sun SunOS 4 and Solaris 2, HP-UX, DEC Ultrix and OSF/1,
  215. IBM AIX, and SCO ODT 3.0.  A Macintosh binary is also available -- a
  216. DOS binary is in the works.
  217.  
  218. If you have a WWW viewer (e.g. Mosaic), you can see all Python
  219. documentation on-line: point your viewer at the URL
  220. http://www.cwi.nl/~guido/Python.html.
  221.  
  222. The source and documentation are available by anonymous ftp from the
  223. following sites -- please pick the one closest to you:
  224.  
  225. Site                    IP address      Directory
  226.  
  227. ftp.cwi.nl        192.16.184.180    /pub/python
  228. gatekeeper.dec.com      16.1.0.2        /pub/plan/python/cwi
  229. ftp.uu.net              192.48.96.9     /languages/python
  230. ftp.fu-berlin.de        130.133.4.50    /pub/unix/languages/python
  231.  
  232. The file is called python1.0.0.tar.Z (some mirror sites convert it to
  233. a .gz file or split it up in separate parts).  See the INDEX file for
  234. other goodies: FAQ, NEWS, PostScript, Emacs info, Mac binary, etc.
  235. (Please don't ask me to mail it to you -- at 1.76 Megabytes it is
  236. unwieldy at least...)
  237.  
  238. There's a mailing list; write to <python-list@cwi.nl> to subscribe (no
  239. LISTSERV commands please).  A FAQ list is regularly posted to
  240. comp.lang.misc.  A newsgroup may be created in the near future.
  241.  
  242. [Excuse the hype -- Python really is a neat language, if I may say so.
  243. Please direct all followups to comp.lang.misc only.]
  244.  
  245. --Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum@cwi.nl>
  246. URL:  <http://www.cwi.nl/cwi/people/Guido.van.Rossum.html>
  247.